package com.kfm.base.io.o;

import com.alibaba.fastjson.JSON;

public class Demo08 {

    public static void main(String[] args) {
        // 通过 json 实现深克隆
        Student friend = new Student("张兴成", 60.1, "男");

        Student stu = new Student("秦爽", 59.9, "男");

        stu.setFriend(friend);

        System.out.println(stu);

        // obj --> jsonString
        String jsonString = JSON.toJSONString(stu);

        // jsonString --> obj
        Student student = JSON.parseObject(jsonString, Student.class);

        System.out.println(student == stu);
        System.out.println(student.getFriend() == stu.getFriend());
        System.out.println(student);

    }
}
